//
//  GmHomeTableListCell.swift
//  d11
//
//  Created by rhonin on 2018/11/22.
//  Copyright © 2018年 Tech_001. All rights reserved.
//

import UIKit

enum viewClickType:String {
    case left = "left"
    case right = "right"
}
class GmHomeTableListCell: UITableViewCell {
    var leftmodel : GameNewsModel?
    var rightMolde : GameNewsModel?
    
    @IBOutlet weak var timeRight: UILabel!
    var viewClick :((viewClickType,GameNewsModel?)->())?
    
    @IBOutlet weak var labRight: UILabel!
    @IBOutlet weak var imageRight: UIImageView!
    @IBOutlet weak var timeLeft: UILabel!
    @IBOutlet weak var lebLeft: UILabel!
    @IBOutlet weak var imageLeft: UIImageView!
    @IBOutlet weak var leftVIew: UIView!
    @IBOutlet weak var rightView: UIView!
    override func awakeFromNib() {
        super.awakeFromNib()
        self.selectionStyle = .none
        let gest = UITapGestureRecognizer(target: self, action: #selector(leftClick(_:)))
        leftVIew.addGestureRecognizer(gest)
        let gestright = UITapGestureRecognizer(target: self, action: #selector(rightClick(_:)))
        rightView.addGestureRecognizer(gestright)
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    func configslef(leftModel:GameNewsModel,rightModel:GameNewsModel?)  {
        self.leftmodel = leftModel
        self.rightMolde = rightModel
        self.lebLeft.text = leftModel.title
        self.timeLeft.text = leftModel.gtmCreate
        self.imageLeft.set_kf_Images(urlString: leftModel.hrefImage, placeHolder: "video_PlaceHolder")
        if rightModel != nil {
            labRight.text = rightModel!.title
            timeRight.text = rightModel!.gtmCreate
            imageRight.set_kf_Images(urlString: rightModel!.hrefImage, placeHolder: "video_PlaceHolder")
            rightView.isHidden = false
        }else{
            rightView.isHidden = true
        }
    }
    @objc func leftClick(_ sender: Any) {
        if viewClick != nil{
            viewClick!(viewClickType.left,leftmodel)
        }
    }
    @objc func rightClick(_ sender: Any) {
        if viewClick != nil{
            viewClick!(viewClickType.right,rightMolde)
        }
    }
}
